import org.molamil.acto.validators.ValidatorResult;
import org.molamil.acto.params.ParamValidatorResult;
import org.molamil.acto.params.ParamContext;

/**
 * @author Jorge Hernandez
 */
class org.molamil.acto.commands.CommandResult {
	
	
	// Constants
	
	public static var STATUS_OK:String = "OK";
	public static var STATUS_ERROR:String = "ERROR";
	public static var STATUS_PENDING:String = "PENDING";
	
	
	// Properties
	
	private var _status:String;	private var _result:Object;	private var _isValidated:Boolean;	private var _validatorResults:Array;
	
	
	// Constructor
	
	public function CommandResult() {
		_isValidated = true;
	}
	
	
	// Functions
	
	public function getParamValidatorResult(name:String):ParamValidatorResult {
		var result:ParamValidatorResult = null;
		for (var i:Number = 0; i < _validatorResults.length; i++) {
			var r:ParamValidatorResult = _validatorResults[i];
			if (r.param.name == name) {
				result = r;
				break;
			}
		}
		return result;
	}

	public function toString():String {
		var s:String = "org.molamil.acto.commands.CommandResult" +
					   "\n\t status = " + _status + 
					   "\n\t result = " + _result +					   "\n\t isValidated = " + _isValidated +					   "\n\t validatorResults = " + _validatorResults;
		return s;
	}

	
	// Getter/Setter
	
	public function get status():String {
		return _status;
	}
	
	public function set status(status:String):Void {
		_status = status;
	}
	
	public function get result():Object {
		return _result;
	}
	
	public function set result(result:Object):Void {
		_result = result;
	}
	
	public function get isValidated():Boolean {
		return _isValidated;
	}

	public function set isValidated(isValidated:Boolean):Void {
		_isValidated = isValidated;
	}
	
	public function get validatorResults():Array {
		return _validatorResults;
	}
	
	public function set validatorResults(validatorResults:Array):Void {
		_validatorResults = validatorResults;
	}
	
	
}
